#set ($name = $info.name.replaceAll("[^A-Za-z0-9_.]", "_"))
#if ($info.arch.toMsiArchitecture() == "arm64")
    #set ($installedVersion = "500")
#else
    #set ($installedVersion = "200")
#end
#set ($id = 0)
#macro(list $file)
	#set($guid = $GUID.randomUUID())
	#set($id = $id + 1)
	#if($file.isDirectory())
	    #if($file.equals(${info.appFolder}))
		<Directory Id="INSTALLFOLDER" Name="${file.name}">
		#else
		<Directory Id="_${id}" Name="${file.name}">
		#end
		#foreach($child in $file.listFiles())
			#list($child)
		#end
		</Directory>
	#else
		<Component Id="_${id}" Guid="${guid}" Win64="yes">
	    #if($file.equals(${info.executable}))
	    	<File Id="EXEFILE" Name="${file.name}" KeyPath="yes" Source="${file}">
				<Shortcut Id="ApplicationStartMenuShortcut" Name="${info.winConfig.shortcutName}" Description="${info.description}" Directory="ProgramMenuFolder" />
	    	</File>
			<RemoveFolder Id="ApplicationProgramsFolder" On="uninstall" />
			<RegistryValue Root="HKLM" Key="Software\\${info.organizationName}\\${info.name}" Name="installed" Type="integer" Value="1" />
		#else
			<File Name="${file.name}" KeyPath="yes" Source="${file}" Id="${file.name.replaceAll("[^A-Za-z0-9_.]", "_")}_${id}"/>
		#end
		</Component>
	#end
#end
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
	<Module Id="${name}_Module" Codepage="1252" Language="1033" Version="${info.winConfig.productVersion}">
		<Package Id="${GUID.randomUUID()}" Manufacturer="${info.organizationName}" InstallerVersion="${installedVersion}" Languages="1033" Platform="${info.arch.toMsiArchitecture()}" SummaryCodepage="1252" Description="${info.description}"/>
		<Directory Id="TARGETDIR" Name="SourceDir">
			#list(${info.appFolder})
			<Directory Id="ProgramMenuFolder" />
#if ($info.winConfig.registry)
			<Component Id="RegistryEntries" Guid="${GUID.randomUUID()}">
#foreach ($entry in $info.winConfig.registry.entries)
				<RegistryKey Root="${entry.root}" Key="${entry.subkey}" ForceDeleteOnUninstall="yes">
					<RegistryValue 
						Type="${entry.valueTypeAsWIXToolsetString}"
#if ($entry.valueName)
						Name="$!{entry.valueName}"
#end
#if ($entry.valueData)
						Value="$!{entry.valueData}"
#end
					/>
				</RegistryKey>
#end
			</Component>
#end
		</Directory>
	</Module>
</Wix>